import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard } from './services/auth.service';

import { LoginComponent } from './components/login/login.component';

const routes: Routes = [
    {
        path: '',
        canActivate: [AuthGuard],
        redirectTo: 'question',
        pathMatch: 'full'
    },
    {
        path: 'login',
        component: LoginComponent,
    },
    {
        path: 'users',
        canActivate: [AuthGuard],
        loadChildren: './pages/users/users.module#UsersModule',
    },
    {
        path: 'case',
        canActivate: [AuthGuard],
        loadChildren: './pages/case/case.module#CaseModule',
    },
    {
        path: 'other',
        loadChildren: './pages/other/other.module#OtherModule',
    },
    {
        path: 'question',
        canActivate: [AuthGuard],
        loadChildren: './pages/question/question.module#QuestionModule',
    },
    {
        path: '**',
        redirectTo: 'other',
        pathMatch: 'full'
    },
];

@NgModule({
    imports: [
        RouterModule.forRoot(routes)
    ],
    exports: [
        RouterModule
    ]
})
export class AppRoutingModule { }
